package com.ehotting.mqbd.zw.api.constants;

public enum ActionConstants {

    shakeHand("shakeHand", (short)-1),
    Cmd_FileSend("Cmd_FileSend", (short)0),
    Cmd_SolverServerReg("Cmd_SolverServerReg", (short)1),
    Cmd_SolverServerUnReg("Cmd_SolverServerUnReg", (short)2),
    Cmd_TaskAppReg("Cmd_TaskAppReg", (short)3),
    Cmd_TaskAppUnreg("Cmd_TaskAppUnreg", (short)4),
    Cmd_TaskAppReReg("Cmd_TaskAppReReg", (short)5),
    Cmd_JobReg("Cmd_JobReg", (short)6),
    Cmd_SolverReg("Cmd_SolverReg", (short)7),
    Cmd_HeartBeat("Cmd_HeartBeat", (short)8),
    Cmd_JobCommit("Cmd_JobCommit", (short)9),
    Cmd_JobCancel("Cmd_JobCancel", (short)10),
    Cmd_JobCompleted("Cmd_JobCompleted", (short)11),
    Cmd_JobCanceled("Cmd_JobCanceled", (short)12),
    Cmd_JobStateAsk("Cmd_JobStateAsk", (short)13),
    Cmd_JobStateAck("Cmd_JobStateAck", (short)14),
    Cmd_TaskLaunching("Cmd_TaskLaunching", (short)15),
    Cmd_TaskStateUpate("Cmd_TaskStateUpate", (short)16),
    Cmd_TaskProgressAsk("Cmd_TaskProgressAsk", (short)17),
    Cmd_TaskProgressAck("Cmd_TaskProgressAck", (short)18),
    Cmd_TaskProgressUpdate("Cmd_TaskProgressUpdate", (short)19),
    Cmd_TaskPauseAsk("Cmd_TaskPauseAsk", (short)20),
    Cmd_TaskPauseAck("Cmd_TaskPauseAck", (short)21),
    Cmd_TaskAbortAsk("Cmd_TaskAbortAsk", (short)22),
    Cmd_TaskAbortAck("Cmd_TaskAbortAck", (short)23),
    Cmd_TaskResumeAsk("Cmd_TaskResumeAsk", (short)24),
    Cmd_TaskResumeAck("Cmd_TaskResumeAck", (short)25),
    Cmd_TaskRefreshAsk("Cmd_TaskRefreshAsk", (short)26),
    Cmd_TaskRefreshAck("Cmd_TaskRefreshAck", (short)27),
    Cmd_TaskComplete("Cmd_TaskComplete", (short)28),
    Cmd_TaskResult("Cmd_TaskResult", (short)29),
    Cmd_TaskLauched("Cmd_TaskLauched", (short)30),
    Cmd_ClusterInfoQuery("Cmd_ClusterInfoQuery", (short)31),
    Cmd_TaskException("Cmd_TaskException", (short)32),
    Cmd_JobException("Cmd_JobException", (short)33),
    Cmd_LauncherException("Cmd_LauncherException", (short)34),
    Cmd_Platform2SolverData("Cmd_Platform2SolverData", (short)35),
    Cmd_Solver2PlatformData("Cmd_Solver2PlatformData", (short)36),
    Cmd_LauncherExit("Cmd_LauncherExit", (short)37),
    Cmd_JobResume("Cmd_JobResume", (short)38),
    Cmd_JobPause("Cmd_JobPause", (short)39),
    Cmd_JobRefresh("Cmd_JobRefresh", (short)40),
    Cmd_ShowSchedulerUI("Cmd_ShowSchedulerUI", (short)41),
    ;

    public static final String shakeHandStr = "shakeHand";
    public static final String Cmd_FileSendStr = "Cmd_FileSend";
    public static final String Cmd_SolverServerRegStr = "Cmd_SolverServerReg";
    public static final String Cmd_SolverServerUnRegStr = "Cmd_SolverServerUnReg";
    public static final String Cmd_TaskAppRegStr = "Cmd_TaskAppReg";
    public static final String Cmd_TaskAppUnregStr = "Cmd_TaskAppUnreg";
    public static final String Cmd_TaskAppReRegStr = "Cmd_TaskAppReReg";
    public static final String Cmd_JobRegStr = "Cmd_JobReg";
    public static final String Cmd_SolverRegStr = "Cmd_SolverReg";
    public static final String Cmd_HeartBeatStr = "Cmd_HeartBeat";
    public static final String Cmd_JobCommitStr = "Cmd_JobCommit";
    public static final String Cmd_JobCancelStr = "Cmd_JobCancel";
    public static final String Cmd_JobCompletedStr = "Cmd_JobCompleted";
    public static final String Cmd_JobCanceledStr = "Cmd_JobCanceled";
    public static final String Cmd_JobStateAskStr = "Cmd_JobStateAsk";
    public static final String Cmd_JobStateAckStr = "Cmd_JobStateAck";
    public static final String Cmd_TaskLaunchingStr = "Cmd_TaskLaunching";
    public static final String Cmd_TaskStateUpateStr = "Cmd_TaskStateUpate";
    public static final String Cmd_TaskProgressAskStr = "Cmd_TaskProgressAsk";
    public static final String Cmd_TaskProgressAckStr = "Cmd_TaskProgressAck";
    public static final String Cmd_TaskProgressUpdateStr = "Cmd_TaskProgressUpdate";
    public static final String Cmd_TaskPauseAskStr = "Cmd_TaskPauseAsk";
    public static final String Cmd_TaskPauseAckStr = "Cmd_TaskPauseAck";
    public static final String Cmd_TaskAbortAskStr = "Cmd_TaskAbortAsk";
    public static final String Cmd_TaskAbortAckStr = "Cmd_TaskAbortAck";
    public static final String Cmd_TaskResumeAskStr = "Cmd_TaskResumeAsk";
    public static final String Cmd_TaskResumeAckStr = "Cmd_TaskResumeAck";
    public static final String Cmd_TaskRefreshAskStr = "Cmd_TaskRefreshAsk";
    public static final String Cmd_TaskRefreshAckStr = "Cmd_TaskRefreshAck";
    public static final String Cmd_TaskCompleteStr = "Cmd_TaskComplete";
    public static final String Cmd_TaskResultStr = "Cmd_TaskResult";
    public static final String Cmd_TaskLauchedStr = "Cmd_TaskLauched";
    public static final String Cmd_ClusterInfoQueryStr = "Cmd_ClusterInfoQuery";
    public static final String Cmd_TaskExceptionStr = "Cmd_TaskException";
    public static final String Cmd_JobExceptionStr = "Cmd_JobException";
    public static final String Cmd_LauncherExceptionStr = "Cmd_LauncherException";
    public static final String Cmd_Platform2SolverDataStr = "Cmd_Platform2SolverData";
    public static final String Cmd_Solver2PlatformDataStr = "Cmd_Solver2PlatformData";
    public static final String Cmd_LauncherExitStr = "Cmd_LauncherExit";
    public static final String Cmd_JobResumeStr = "Cmd_JobResume";
    public static final String Cmd_JobPauseStr = "Cmd_JobPause";
    public static final String Cmd_JobRefreshStr = "Cmd_JobRefresh";
    public static final String Cmd_ShowSchedulerUIStr = "Cmd_ShowSchedulerUI";

    /**
     * 用于以和客户端处理器的命名
     */
    private String actionName;
    /**
     * 用于传输到中望服务端的值，参考中望提供的头文件枚举信息，从上到下排序
     */
    private short zwCommandVal;

    ActionConstants(String actionName, short zwCommandVal) {
        this.actionName = actionName;
        this.zwCommandVal = zwCommandVal;
    }

    public String getActionName() {
        return actionName;
    }

    public short getZwCommandVal() {
        return zwCommandVal;
    }

    public static ActionConstants getByActionName(String actionName) {
        for (ActionConstants actionConstant : ActionConstants.values()) {
            if (actionConstant.getActionName().equals(actionName)) {
                return actionConstant;
            }
        }
        return shakeHand;
    }

    public static ActionConstants getByCommandVal(short zwCommandVal) {
        for (ActionConstants actionConstant : ActionConstants.values()) {
            if (zwCommandVal == actionConstant.getZwCommandVal()) {
                return actionConstant;
            }
        }
        return shakeHand;
    }
}
